package com.adcc.loadsheet.billing.controller;

import com.adcc.loadsheet.billing.vo.ResultStatus;
import com.adcc.loadsheet.billing.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * 校验验证码Controller层
 * Created by zhaoml on 2020/4/10.
 */
@Controller
@RequestMapping(value = "validatecode")
@Api(value = "/validatecode", description = "校验验证码相关操作controller")
public class ValidateCodeController extends BasisController{

    @GetMapping(value = "checkverify")
    @ApiOperation(value = "/checkverify", notes = "校验验证码", httpMethod = "GET")
    @ResponseBody
    public ResultVO checkVerify(String verifyInput) {
        ResultVO vo = new ResultVO();
        try{
            //从session中获取随机数
            String inputStr = verifyInput;
            /*String random = (String) session.getAttribute("validateCode");
            if (random == null) {
                vo.setStatus(ResultStatus.FAILED);
                vo.setErrorReason("请输入验证码！");
                return vo;
            }
            if (random.equals(inputStr)) {
                vo.setStatus(ResultStatus.SUCCESS);
                vo.getData().put("msg", "SUCCESS");
            } else {
                vo.setStatus(ResultStatus.FAILED);
                vo.setErrorReason("验证码错误！");
            }*/
        }catch (Exception e){
            vo.setStatus(ResultStatus.FAILED);
            vo.setErrorReason("验证码错误！");
        }
        return vo;
    }
}